(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseGovPerson: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseGovPersonInfo: {
                govPersons: [],
                _currentGovPersonName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseGovPerson', 'openChooseGovPersonModel', function (_param) {
                $('#chooseGovPersonModel').modal('show');
                vc.component._refreshChooseGovPersonInfo();
                vc.component._loadAllGovPersonInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllGovPersonInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        communityId: vc.getCurrentCommunity().communityId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('govPerson.listGovPersons',
                    param,
                    function (json) {
                        var _govPersonInfo = JSON.parse(json);
                        vc.component.chooseGovPersonInfo.govPersons = _govPersonInfo.govPersons;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseGovPerson: function (_govPerson) {
                if (_govPerson.hasOwnProperty('name')) {
                    _govPerson.govPersonName = _govPerson.name;
                }
                vc.emit($props.emitChooseGovPerson, 'chooseGovPerson', _govPerson);
                vc.emit($props.emitLoadData, 'listGovPersonData', {
                    govPersonId: _govPerson.govPersonId
                });
                $('#chooseGovPersonModel').modal('hide');
            },
            queryGovPersons: function () {
                vc.component._loadAllGovPersonInfo(1, 10, vc.component.chooseGovPersonInfo._currentGovPersonName);
            },
            _refreshChooseGovPersonInfo: function () {
                vc.component.chooseGovPersonInfo._currentGovPersonName = "";
            }
        }

    });
})(window.vc);
